﻿/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Computer System Class
 *		Represents and retrieves information about the local machine from the 
 * Windows Management Instrumentation system.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using System.Threading;
using System.ServiceProcess;
using System.Windows.Forms;
using System.ComponentModel;

namespace Adaptive.Foundation.SysTools
{
    /// <summary>
    /// Represents and retrieves information about the local machine from the 
    /// Windows Management Instrumentation system.
    /// </summary>
    public sealed class ComputerSystem : AiObjectBase
    {
        /*--------------------------------------------------------------------------------
         * Private Member Declarations
         *------------------------------------------------------------------------------*/
        #region Private Member Declarations
        private string _bootDevice = string.Empty;
        private string _buildNumber = string.Empty;
        private string _buildType = string.Empty;
        private string _caption = string.Empty;
        private string _codeSet = string.Empty;
        private string _countryCode = string.Empty;
        private string _creationClassName = string.Empty;
        private string _csCreationClassName = string.Empty;
        private string _csdVersion = string.Empty;
        private string _csName = string.Empty;
        private short _currentTimeZone;
        private bool _dataExecutionPrevention_32BitApplications;
        private bool _dataExecutionPrevention_Available;
        private bool _dataExecutionPrevention_Drivers;
        private bool _debug;
        private string _description = string.Empty;
        private bool _distributed;
        private uint _encryptionLevel;
        private byte _foregroundApplicationBoost;
        private ulong _freePhysicalMemory;
        private ulong _freeSpaceInPagingFiles;
        private ulong _freeVirtualMemory;
        private DateTime _installDate;
        private uint _largeSystemCache;
        private DateTime _lastBootUpTime;
        private DateTime _localDateTime;
        private string _locale = string.Empty;
        private string _manufacturer = string.Empty;
        private uint _maxNumberOfProcesses;
        private ulong _maxProcessMemorySize;
        private int _numberOfLicensedUsers;
        private uint _numberOfProcesses;
        private uint _numberOfUsers;
        private string _organization = string.Empty;
        private uint _osLanguage;
        private int _osProductSuite;
        private ushort _osType;
        private int _otherTypeDescription;
        private int _plusProductID;
        private int _plusVersionNumber;
        private bool _populated;
        private bool _primary;
        private uint _productType;
        private byte _quantumLength;
        private byte _quantumType;
        private string _registeredUser = string.Empty;
        private string _serialNumber = string.Empty;
        private ushort _servicePackMajorVersion;
        private ushort _servicePackMinorVersion;
        private ulong _sizeStoredInPagingFiles;
        private string _status = string.Empty;
        private uint _suiteMask;
        private string _systemDevice = string.Empty;
        private string _systemDirectory = string.Empty;
        private string _systemDrive = string.Empty;
        private int _totalSwapSpaceSize;
        private ulong _totalVirtualMemorySize;
        private ulong _totalVisibleMemorySize;
        private string _version = string.Empty;
        private string _windowsDirectory = string.Empty;
        #endregion

        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
         *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the <see cref="ComputerSystem"/> class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        public ComputerSystem()
        {
            _populated = this.Populate();
        }
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><b>true</b> to release both managed and unmanaged resources; 
        /// <b>false</b> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            _bootDevice = null;
            _buildNumber = null;
            _buildType = null;
            _caption = null;
            _codeSet = null;
            _countryCode = null;
            _creationClassName = null;
            _csCreationClassName = null;
            _csdVersion = null;
            _csName = null;
            _registeredUser = null;
            _serialNumber = null;
            _status = null;
            _systemDevice = null;
            _systemDirectory = null;
            _systemDrive = null;
            _version = null;
            _windowsDirectory = null;
            _description = null;
            _locale = null;
            _manufacturer = null;
            _organization = null;
            base.Dispose(disposing);
        }
        #endregion


        /*--------------------------------------------------------------------------------
         * Public Properties
         *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the name or description of the boot device.
        /// </summary>
        /// <value>The name or description of the boot device.</value>
        [Browsable(true), DefaultValue(""), Category("OS Information"),
         Description("The name or description of the boot device."), ReadOnly(true)]
        public string BootDevice
        {
            get
            {
                return _bootDevice;
            }
        }
        /// <summary>
        /// Gets the build number value for the operating system.
        /// </summary>
        /// <value>The operating system build number.</value>
        [Browsable(true), DefaultValue(""), Category("OS Information"),
         Description("The operating system build number."), ReadOnly(true)]
        public string BuildNumber
        {
            get
            {
                return _buildNumber;
            }
        }
        /// <summary>
        /// Gets the operating system build type description.
        /// </summary>
        /// <value>The operating system build type description.</value>
        [Browsable(true), DefaultValue(""), Category("OS Information"),
         Description("The operating system build type description."), ReadOnly(true)]
        public string BuildType
        {
            get
            {
                return _buildType;
            }
        }

        /// <summary>
        /// Gets the general caption or display name for the operating system.
        /// </summary>
        /// <value>The general caption or display name for the operating system.</value>
        [Browsable(true), DefaultValue(""), Category("OS Information"),
         Description("The general caption or display name for the operating system."), ReadOnly(true)]
        public string Caption
        {
            get
            {
                return _caption;
            }
        }

        /// <summary>
        /// Gets the code set.
        /// </summary>
        /// <value>The code set.</value>
        public string CodeSet
        {
            get
            {
                return _codeSet;
            }
        }

        /// <summary>
        /// Gets the country code.
        /// </summary>
        /// <value>The country code.</value>
        public string CountryCode
        {
            get
            {
                return _countryCode;
            }
        }

        /// <summary>
        /// Gets the name of the creation class.
        /// </summary>
        /// <value>The name of the creation class.</value>
        public string CreationClassName
        {
            get
            {
                return _creationClassName;
            }
        }

        /// <summary>
        /// Gets the name of the CS creation class.
        /// </summary>
        /// <value>The name of the CS creation class.</value>
        public string CSCreationClassName
        {
            get
            {
                return _csCreationClassName;
            }
        }

        /// <summary>
        /// Gets the CSD version.
        /// </summary>
        /// <value>The CSD version.</value>
        public string CSDVersion
        {
            get
            {
                return _csdVersion;
            }
        }

        /// <summary>
        /// Gets the name of the CS.
        /// </summary>
        /// <value>The name of the CS.</value>
        public string CSName
        {
            get
            {
                return _csName;
            }
        }

        /// <summary>
        /// Gets the current time zone.
        /// </summary>
        /// <value>The current time zone.</value>
        public short CurrentTimeZone
        {
            get
            {
                return _currentTimeZone;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [data execution prevention_32 bit applications].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [data execution prevention_32 bit applications]; otherwise, <c>false</c>.
        /// </value>
        public bool DataExecutionPrevention_32BitApplications
        {
            get
            {
                return _dataExecutionPrevention_32BitApplications;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [data execution prevention_ available].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [data execution prevention_ available]; otherwise, <c>false</c>.
        /// </value>
        public bool DataExecutionPrevention_Available
        {
            get
            {
                return _dataExecutionPrevention_Available;
            }
        }

        /// <summary>
        /// Gets a value indicating whether [data execution prevention_ drivers].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [data execution prevention_ drivers]; otherwise, <c>false</c>.
        /// </value>
        public bool DataExecutionPrevention_Drivers
        {
            get
            {
                return _dataExecutionPrevention_Drivers;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this <see cref="ComputerSystem"/> is debug.
        /// </summary>
        /// <value><c>true</c> if debug; otherwise, <c>false</c>.</value>
        public bool Debug
        {
            get
            {
                return _debug;
            }
        }

        /// <summary>
        /// Gets the description.
        /// </summary>
        /// <value>The description.</value>
        public string Description
        {
            get
            {
                return _description;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this <see cref="ComputerSystem"/> is distributed.
        /// </summary>
        /// <value><c>true</c> if distributed; otherwise, <c>false</c>.</value>
        public bool Distributed
        {
            get
            {
                return _distributed;
            }
        }

        /// <summary>
        /// Gets the encryption level.
        /// </summary>
        /// <value>The encryption level.</value>
        public uint EncryptionLevel
        {
            get
            {
                return _encryptionLevel;
            }
        }

        /// <summary>
        /// Gets the foreground application boost.
        /// </summary>
        /// <value>The foreground application boost.</value>
        public byte ForegroundApplicationBoost
        {
            get
            {
                return _foregroundApplicationBoost;
            }
        }

        /// <summary>
        /// Gets the free physical memory.
        /// </summary>
        /// <value>The free physical memory.</value>
        public ulong FreePhysicalMemory
        {
            get
            {
                return _freePhysicalMemory;
            }
        }

        /// <summary>
        /// Gets the free space in paging files.
        /// </summary>
        /// <value>The free space in paging files.</value>
        public ulong FreeSpaceInPagingFiles
        {
            get
            {
                return _freeSpaceInPagingFiles;
            }
        }

        /// <summary>
        /// Gets the free virtual memory.
        /// </summary>
        /// <value>The free virtual memory.</value>
        public ulong FreeVirtualMemory
        {
            get
            {
                return _freeVirtualMemory;
            }
        }

        /// <summary>
        /// Gets the install date.
        /// </summary>
        /// <value>The install date.</value>
        public DateTime InstallDate
        {
            get
            {
                return _installDate;
            }
        }

        /// <summary>
        /// Gets the large system cache.
        /// </summary>
        /// <value>The large system cache.</value>
        public uint LargeSystemCache
        {
            get
            {
                return _largeSystemCache;
            }
        }

        /// <summary>
        /// Gets the last boot up time.
        /// </summary>
        /// <value>The last boot up time.</value>
        public DateTime LastBootUpTime
        {
            get
            {
                return _lastBootUpTime;
            }
        }

        /// <summary>
        /// Gets the local date time.
        /// </summary>
        /// <value>The local date time.</value>
        public DateTime LocalDateTime
        {
            get
            {
                return _localDateTime;
            }
        }

        /// <summary>
        /// Gets the locale.
        /// </summary>
        /// <value>The locale.</value>
        public string Locale
        {
            get
            {
                return _locale;
            }
        }

        /// <summary>
        /// Gets the manufacturer.
        /// </summary>
        /// <value>The manufacturer.</value>
        public string Manufacturer
        {
            get
            {
                return _manufacturer;
            }
        }

        /// <summary>
        /// Gets the max number of processes.
        /// </summary>
        /// <value>The max number of processes.</value>
        public uint MaxNumberOfProcesses
        {
            get
            {
                return _maxNumberOfProcesses;
            }
        }

        /// <summary>
        /// Gets the size of the max process memory.
        /// </summary>
        /// <value>The size of the max process memory.</value>
        public ulong MaxProcessMemorySize
        {
            get
            {
                return _maxProcessMemorySize;
            }
        }

        /// <summary>
        /// Gets the number of licensed users.
        /// </summary>
        /// <value>The number of licensed users.</value>
        public int NumberOfLicensedUsers
        {
            get
            {
                return _numberOfLicensedUsers;
            }
        }

        /// <summary>
        /// Gets the number of processes.
        /// </summary>
        /// <value>The number of processes.</value>
        public uint NumberOfProcesses
        {
            get
            {
                return _numberOfProcesses;
            }
        }

        /// <summary>
        /// Gets the number of users.
        /// </summary>
        /// <value>The number of users.</value>
        public uint NumberOfUsers
        {
            get
            {
                return _numberOfUsers;
            }
        }

        /// <summary>
        /// Gets the organization.
        /// </summary>
        /// <value>The organization.</value>
        public string Organization
        {
            get
            {
                return _organization;
            }
        }

        /// <summary>
        /// Gets the OS language.
        /// </summary>
        /// <value>The OS language.</value>
        public uint OSLanguage
        {
            get
            {
                return _osLanguage;
            }
        }

        /// <summary>
        /// Gets the OS product suite.
        /// </summary>
        /// <value>The OS product suite.</value>
        public int OSProductSuite
        {
            get
            {
                return _osProductSuite;
            }
        }

        /// <summary>
        /// Gets the type of the OS.
        /// </summary>
        /// <value>The type of the OS.</value>
        public ushort OSType
        {
            get
            {
                return _osType;
            }
        }

        /// <summary>
        /// Gets the other type description.
        /// </summary>
        /// <value>The other type description.</value>
        public int OtherTypeDescription
        {
            get
            {
                return _otherTypeDescription;
            }
        }

        /// <summary>
        /// Gets the plus product ID.
        /// </summary>
        /// <value>The plus product ID.</value>
        public int PlusProductID
        {
            get
            {
                return _plusProductID;
            }
        }

        /// <summary>
        /// Gets the plus version number.
        /// </summary>
        /// <value>The plus version number.</value>
        public int PlusVersionNumber
        {
            get
            {
                return _plusVersionNumber;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this <see cref="ComputerSystem"/> is populated.
        /// </summary>
        /// <value><c>true</c> if populated; otherwise, <c>false</c>.</value>
        public bool Populated
        {
            get
            {
                return _populated;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this <see cref="ComputerSystem"/> is primary.
        /// </summary>
        /// <value><c>true</c> if primary; otherwise, <c>false</c>.</value>
        public bool Primary
        {
            get
            {
                return _primary;
            }
        }

        /// <summary>
        /// Gets the type of the product.
        /// </summary>
        /// <value>The type of the product.</value>
        public uint ProductType
        {
            get
            {
                return _productType;
            }
        }

        /// <summary>
        /// Gets the length of the quantum.
        /// </summary>
        /// <value>The length of the quantum.</value>
        public byte QuantumLength
        {
            get
            {
                return _quantumLength;
            }
        }

        /// <summary>
        /// Gets the type of the quantum.
        /// </summary>
        /// <value>The type of the quantum.</value>
        public byte QuantumType
        {
            get
            {
                return _quantumType;
            }
        }

        /// <summary>
        /// Gets the registered user.
        /// </summary>
        /// <value>The registered user.</value>
        public string RegisteredUser
        {
            get
            {
                return _registeredUser;
            }
        }

        /// <summary>
        /// Gets the serial number.
        /// </summary>
        /// <value>The serial number.</value>
        public string SerialNumber
        {
            get
            {
                return _serialNumber;
            }
        }

        /// <summary>
        /// Gets the service pack major version.
        /// </summary>
        /// <value>The service pack major version.</value>
        public ushort ServicePackMajorVersion
        {
            get
            {
                return _servicePackMajorVersion;
            }
        }

        /// <summary>
        /// Gets the service pack minor version.
        /// </summary>
        /// <value>The service pack minor version.</value>
        public ushort ServicePackMinorVersion
        {
            get
            {
                return _servicePackMinorVersion;
            }
        }

        /// <summary>
        /// Gets the size stored in paging files.
        /// </summary>
        /// <value>The size stored in paging files.</value>
        public ulong SizeStoredInPagingFiles
        {
            get
            {
                return _sizeStoredInPagingFiles;
            }
        }

        /// <summary>
        /// Gets the status.
        /// </summary>
        /// <value>The status.</value>
        public string Status
        {
            get
            {
                return _status;
            }
        }

        /// <summary>
        /// Gets the suite mask.
        /// </summary>
        /// <value>The suite mask.</value>
        public uint SuiteMask
        {
            get
            {
                return _suiteMask;
            }
        }

        /// <summary>
        /// Gets the system device.
        /// </summary>
        /// <value>The system device.</value>
        public string SystemDevice
        {
            get
            {
                return _systemDevice;
            }
        }

        /// <summary>
        /// Gets the system directory.
        /// </summary>
        /// <value>The system directory.</value>
        public string SystemDirectory
        {
            get
            {
                return _systemDirectory;
            }
        }

        /// <summary>
        /// Gets the system drive.
        /// </summary>
        /// <value>The system drive.</value>
        public string SystemDrive
        {
            get
            {
                return _systemDrive;
            }
        }

        /// <summary>
        /// Gets the total size of the swap space.
        /// </summary>
        /// <value>The total size of the swap space.</value>
        public int TotalSwapSpaceSize
        {
            get
            {
                return _totalSwapSpaceSize;
            }
        }

        /// <summary>
        /// Gets the total size of the virtual memory.
        /// </summary>
        /// <value>The total size of the virtual memory.</value>
        public ulong TotalVirtualMemorySize
        {
            get
            {
                return _totalVirtualMemorySize;
            }
        }

        /// <summary>
        /// Gets the total size of the visible memory.
        /// </summary>
        /// <value>The total size of the visible memory.</value>
        public ulong TotalVisibleMemorySize
        {
            get
            {
                return _totalVisibleMemorySize;
            }
        }

        /// <summary>
        /// Gets the version.
        /// </summary>
        /// <value>The version.</value>
        public string Version
        {
            get
            {
                return _version;
            }
        }

        /// <summary>
        /// Gets the windows directory.
        /// </summary>
        /// <value>The windows directory.</value>
        public string WindowsDirectory
        {
            get
            {
                return _windowsDirectory;
            }
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Private Methods / Functions
         *------------------------------------------------------------------------------*/
        #region Private Methods / Functions
        /// <summary>
        /// Parses the date.
        /// </summary>
        /// <param name="original">The original.</param>
        /// <returns>
        /// A <see cref="DateTime"/> instance.
        /// </returns>
        private DateTime ParseDate(string original)
        {
            int year = 0;
            int day = 0;
            int month = 0;
            int hour = 0;
            int minute = 0;

            year = Convert.ToInt32(original.Substring(0, 4));
            month = Convert.ToInt32(original.Substring(4, 2));
            day = Convert.ToInt32(original.Substring(6, 2));
            hour = Convert.ToInt32(original.Substring(8, 2));
            minute = Convert.ToInt32(original.Substring(10, 2));

            return new DateTime(year, month, day, hour, minute, Convert.ToInt32(original.Substring(12, 2)));
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Public Methods / Functions
         *------------------------------------------------------------------------------*/
        #region Public Methods / Functions
        /// <summary>
        /// Populates this instance with the information for the local machine.
        /// </summary>
        /// <returns>
        /// <b>true</b> if the operation is successful; otherwise, <b>false</b>.
        /// </returns>
        public bool Populate()
        {
            WmiQueryResultCollection[] wmiDataList = null;
            WmiQueryResultCollection itemList = null;
            bool returnValue = false;

            try
            {
                wmiDataList = WmiQuery.GetWMIData("SELECT * FROM Win32_OperatingSystem");
                if ((wmiDataList != null) && (wmiDataList.Length > 0))
                {
                    itemList = wmiDataList[0];
                    _bootDevice = (string)itemList["BootDevice"].OriginalData;
                    _buildNumber = (string)itemList["BuildNumber"].OriginalData;
                    _buildType = (string)itemList["BuildType"].OriginalData;
                    _caption = (string)itemList["Caption"].OriginalData;
                    _codeSet = (string)itemList["CodeSet"].OriginalData;
                    _countryCode = (string)itemList["CountryCode"].OriginalData;
                    _creationClassName = (string)itemList["CreationClassName"].OriginalData;
                    _csCreationClassName = (string)itemList["CSCreationClassName"].OriginalData;
                    _csdVersion = (string)itemList["CSDVersion"].OriginalData;
                    _csName = (string)itemList["CSName"].OriginalData;
                    _currentTimeZone = (short)itemList["CurrentTimeZone"].OriginalData;
                    _dataExecutionPrevention_32BitApplications = (bool)itemList["DataExecutionPrevention_32BitApplications"].OriginalData;
                    _dataExecutionPrevention_Available = (bool)itemList["DataExecutionPrevention_Available"].OriginalData;
                    _dataExecutionPrevention_Drivers = (bool)itemList["DataExecutionPrevention_Drivers"].OriginalData;
                    _debug = (bool)itemList["Debug"].OriginalData;
                    _description = (string)itemList["Description"].OriginalData;
                    _distributed = (bool)itemList["Distributed"].OriginalData;
                    _encryptionLevel = (uint)itemList["EncryptionLevel"].OriginalData;
                    _foregroundApplicationBoost = (byte)itemList["ForegroundApplicationBoost"].OriginalData;
                    _freePhysicalMemory = (ulong)itemList["FreePhysicalMemory"].OriginalData;
                    _freeSpaceInPagingFiles = (ulong)itemList["FreeSpaceInPagingFiles"].OriginalData;
                    _freeVirtualMemory = (ulong)itemList["FreeVirtualMemory"].OriginalData;
                    _installDate = ParseDate((string)itemList["InstallDate"].OriginalData);
                    _largeSystemCache = (uint)itemList["LargeSystemCache"].OriginalData;
                    _lastBootUpTime = ParseDate((string)itemList["LastBootUpTime"].OriginalData);
                    _localDateTime = ParseDate((string)itemList["LocalDateTime"].OriginalData);
                    _locale = (string)itemList["Locale"].OriginalData;
                    _manufacturer = (string)itemList["Manufacturer"].OriginalData;
                    _maxNumberOfProcesses = (uint)itemList["MaxNumberOfProcesses"].OriginalData;
                    _maxProcessMemorySize = (ulong)itemList["MaxProcessMemorySize"].OriginalData;
                    Name = (string)itemList["Name"].OriginalData;
                    _numberOfLicensedUsers = (int)itemList["NumberOfLicensedUsers"].OriginalData;
                    _numberOfProcesses = (uint)itemList["NumberOfProcesses"].OriginalData;
                    _numberOfUsers = (uint)itemList["NumberOfUsers"].OriginalData;
                    _organization = (string)itemList["Organization"].OriginalData;
                    _osLanguage = (uint)itemList["OSLanguage"].OriginalData;
                    _osProductSuite = (int)itemList["OSProductSuite"].OriginalData;
                    _osType = (ushort)itemList["OSType"].OriginalData;
                    _otherTypeDescription = (int)itemList["OtherTypeDescription"].OriginalData;
                    _plusProductID = (int)itemList["PlusProductID"].OriginalData;
                    _plusVersionNumber = (int)itemList["PlusVersionNumber"].OriginalData;
                    _primary = (bool)itemList["Primary"].OriginalData;
                    _productType = (uint)itemList["ProductType"].OriginalData;
                    _quantumLength = (byte)itemList["QuantumLength"].OriginalData;
                    _quantumType = (byte)itemList["QuantumType"].OriginalData;
                    _registeredUser = (string)itemList["RegisteredUser"].OriginalData;
                    _serialNumber = (string)itemList["SerialNumber"].OriginalData;
                    _servicePackMajorVersion = (ushort)itemList["ServicePackMajorVersion"].OriginalData;
                    _servicePackMinorVersion = (ushort)itemList["ServicePackMinorVersion"].OriginalData;
                    _sizeStoredInPagingFiles = (ulong)itemList["SizeStoredInPagingFiles"].OriginalData;
                    _status = (string)itemList["Status"].OriginalData;
                    _suiteMask = (uint)itemList["SuiteMask"].OriginalData;
                    _systemDevice = (string)itemList["SystemDevice"].OriginalData;
                    _systemDirectory = (string)itemList["SystemDirectory"].OriginalData;
                    _systemDrive = (string)itemList["SystemDrive"].OriginalData;
                    _totalSwapSpaceSize = (int)itemList["TotalSwapSpaceSize"].OriginalData;
                    _totalVirtualMemorySize = (ulong)itemList["TotalVirtualMemorySize"].OriginalData;
                    _totalVisibleMemorySize = (ulong)itemList["TotalVisibleMemorySize"].OriginalData;
                    _version = (string)itemList["Version"].OriginalData;
                    _windowsDirectory = (string)itemList["WindowsDirectory"].OriginalData;

                    itemList.ClearAndDispose();
                    Array.Clear(wmiDataList, 0, wmiDataList.Length);
                    returnValue = true;
                }
            }
            catch
            {
            }
            itemList = null;
            wmiDataList = null;

            return returnValue;
        }
        #endregion
    }
}